package com.liao.learntest;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;

import io.minio.MinioClient;
import io.minio.errors.MinioException;
import org.apache.commons.io.FileUtils;

/**
 * @author liaowenqiang
 */
public class FileUploader {
  public static void main(String[] args) throws Exception {
    try {
      // 使用Minio服务的URL，端口，Access key和Secret key创建一个MinioClient对象
      MinioClient minioClient = new MinioClient("https://minio.smxzhcs.cn", "AggOjTPeeXdHBsnr", "yUHV9DWq83VBDA895PDPQ0W3hpy1AYGG");
      InputStream object = minioClient.getObject("gtgs-prod", "/upload/20230615/51f1b1b5bbe7379e420cf65f35a25ce1.jpeg");
      File file = new File("/Users/liaowenqiang/2015.jpg");

      FileUtils.copyInputStreamToFile(object,file);

    } catch(MinioException e) {
      System.out.println("Error occurred: " + e);
    }
  }
}